import sys
import os
import re


#Joseph Jessup

#global names

def ReadFile(f):
    print 'Start'
    lineNum = 0
    names = []
    line = 'start'
    while len(line) != 0:
        line = f.readline()
        lineNum = lineNum + 1
        #print str(lineNum)
        parse(line, lineNum)

def parse(line, lineNum):

    check = line.rfind('<')
    if check == -1:
        if lineNum > 200: 
            return
    okay = 0
    if line.rfind('<?') != -1:
        return
    if line.rfind('!--') != -1:
        return

    tag = r'<(/*\w+)\s*.{0,50}?>+'
    match = re.findall(tag,line)
    #search(tag,line)
    if match:
        okay = 0
        for name in match:
            okay = 0
            #if name.rfind('/') != -1:
                #tag = re.search(r'/(.+)',name)
                
                #Search through list then Print out Error Message
                #names.remove(tag.group())
            #else:
                #names.append(name)
    else:
         print 'Error Line ' + str(lineNum)
         #return error = str(lineNum)
            
        

print 'TEST 1'
file = open(os.getcwd() + '\\motion0.xml')
ReadFile(file)

print 'TEST 2'
file = open(os.getcwd() + '\\motion1.xml')
ReadFile(file)

print 'TEST 3'
file = open(os.getcwd() + '\\motion2.xml')
ReadFile(file)

print 'TEST 4'
file = open(os.getcwd() + '\\motion3.xml')
ReadFile(file)

print 'END TESTS'
